package com.ronin.managed.bean;

import com.ronin.commmon.beans.util.JsfUtil;
import com.ronin.managed.bean.lazydatamodel.MusteriDataModel;
import com.ronin.model.Musteri;
import com.ronin.model.kriter.MusteriSorguKriteri;
import com.ronin.service.IMusteriService;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import org.apache.log4j.Logger;

@ManagedBean(name = "musteriMB")
@ViewScoped
public class MusteriMB implements Serializable {
    
    public static Logger logger = Logger.getLogger(MusteriMB.class);
    
    private Musteri musteri;
    private MusteriDataModel musteriList;
    private List<Musteri> filteredMusteriList;
    
    private MusteriSorguKriteri musteriSorguKriteri;

    @ManagedProperty("#{musteriService}")
    private IMusteriService musteriService;

    @PostConstruct
    public void init() {
        musteriList = new MusteriDataModel(musteriService, musteriSorguKriteri);
    }

    public void getList(){
        
    }
    
    public void add(Musteri musteri) {
        try {
            musteriService.add(musteri);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");

    }

    public void update(Musteri musteri) {
        try {
            musteriService.update(musteri);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");
    }

    public void delete(Musteri musteri) {
        try {
            musteriService.update(musteri);
        } catch (Exception e) {
            logger.error(e.getStackTrace());
            JsfUtil.addSuccessMessage("Hata!");
        }
        JsfUtil.addSuccessMessage("?slem basarili");
    }

    public IMusteriService getMusteriService() {
        return musteriService;
    }

    public void setMusteriService(IMusteriService musteriService) {
        this.musteriService = musteriService;
    }

    public Musteri getMusteri() {
        return musteri;
    }

    public void setMusteri(Musteri musteri) {
        this.musteri = musteri;
    }

    public MusteriDataModel getMusteriList() {
        return musteriList;
    }

    public void setMusteriList(MusteriDataModel musteriList) {
        this.musteriList = musteriList;
    }

    public List<Musteri> getFilteredMusteriList() {
        return filteredMusteriList;
    }

    public void setFilteredMusteriList(List<Musteri> filteredMusteriList) {
        this.filteredMusteriList = filteredMusteriList;
    }

    public MusteriSorguKriteri getMusteriSorguKriteri() {
        return musteriSorguKriteri;
    }

    public void setMusteriSorguKriteri(MusteriSorguKriteri musteriSorguKriteri) {
        this.musteriSorguKriteri = musteriSorguKriteri;
    }
    
    
}
